package cn.kgm.template.api.factory;

import cn.kgm.core.http.response.R;
import cn.kgm.template.api.TemplateCheckedFeignApi;
import cn.kgm.template.dto.dto.TemplateCheckedSaveDTO;
import cn.kgm.template.dto.dto.TemplateCheckedUpdateDTO;
import cn.kgm.template.dto.query.TemplateCheckedPageQuery;
import cn.kgm.template.dto.vo.TemplateCheckedVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * # 技术改变自己 #
 * 模板数据,select标签表选中数据
 *
 * @author kapp-i
 * @email yolo.jk@qq.com
 * @date 2024-03-18 15:23:38
 */
@Slf4j
@Component
public class TemplateCheckedFallbackFactory implements FallbackFactory<TemplateCheckedFeignApi> {

    @Override
    public TemplateCheckedFeignApi create(Throwable throwable) {
        throwable.printStackTrace();
        log.error("模板数据,select标签表选中数据服务调用失败===>{}", throwable.getMessage());
        return new TemplateCheckedFeignApi() {

            @Override
            public R<IPage<TemplateCheckedVO>> page(TemplateCheckedPageQuery data) {
                return R.fail("模板数据,select标签表选中数据,【page】方法调用失败===>" + throwable.getMessage());
            }

            @Override
            public R<TemplateCheckedVO> get(@PathVariable(value = "id") Long id) {
                return R.fail("模板数据,select标签表选中数据,【get】方法调用失败===>" + throwable.getMessage());
            }

            @Override
            public R<Boolean> save(@RequestBody @Validated TemplateCheckedSaveDTO data) {
                return R.fail("模板数据,select标签表选中数据,【save】方法调用失败===>" + throwable.getMessage());
            }

            @Override
            public R<Boolean> update(@RequestBody @Validated TemplateCheckedUpdateDTO data) {
                return R.fail("模板数据,select标签表选中数据,【update】方法调用失败===>" + throwable.getMessage());
            }

            @Override
            public R<Boolean> delete(@PathVariable(value = "ids") Long[] ids) {
                return R.fail("模板数据,select标签表选中数据,【delete】方法调用失败===>" + throwable.getMessage());
            }
        };
    }
}

